<script>
import { getParamByQr } from './utils'
export default {
  onLaunch: function(data) {
    console.log('launch data:', data)
    // 检查小程序升级
    if (uni.canIUse('getUpdateManager')) {
      const updateManager = uni.getUpdateManager();
      updateManager.onCheckForUpdate((res) => {
        if (res.hasUpdate) {
          updateManager.onUpdateReady(() => {
            uni.showModal({
              title: '更新提示',
              content: '新版本已发布,请重启当前应用!',
              showCancel: false,
              success(result) {
                if (result.confirm) {
                  updateManager.applyUpdate();
                }
              }
            });
          });
        }
      });
      updateManager.onUpdateFailed(() => {
        uni.showModal({
          title: '发现新版本',
          content: '请删除当前小程序,重新搜索打开'
        });
      });
    }
  },
  onShow: function(data) {
    if (data.shareTicket) {
      this.globalData.shareTicket = data.shareTicket
    }
    if (data.query.q) {
      const qrPath = decodeURIComponent(data.query.q)
      this.globalData.qrGatewayId = getParamByQr(qrPath, 'gw')
      this.globalData.qrVideoId = getParamByQr(qrPath, 'v')
    }
    console.log('App Show', data)
  },
  onHide: function() {
    console.log('App Hide')
  },
  globalData: {
  }
};
</script>

<style lang="scss">
/*每个页面公共css */
@import '@/uni_modules/uni-scss/index.scss';
@import '@/static/iconfont.css';
/* #ifndef APP-NVUE */
// 设置整个项目的背景色
page {
  background-color: $background-base;
  color: $text-main;
}
view {
  box-sizing: border-box;
  word-break: break-all;
}

/* #endif */
</style>
